//
//  SAMemberTopUpRecordVC.m
//  saasRetail
//
//  Created by mac on 2023/3/6.
//

#import "SAMemberTopUpRecordVC.h"
#import "SASystemStoreStoreListAPI.h"
#import "SAStoreModel.h"
#import "BubbleTableView.h"
#import "HDDatePickerView.h"
#import "SAMemberTopUpRecordCell.h"
#import "SAMemberTopUpRecordModel.h"
#import "SAStatisticsProfitDetailVC.h"
#import "SAMemberQueryRechargeAPI.h"
#import "SATopUpScreeningView.h"

@interface SAMemberTopUpRecordVC ()<UITableViewDelegate, UITableViewDataSource, HTTPAPIDelegate>

@property (nonatomic, strong) UIView *topContentView;
@property (nonatomic, strong) UILabel *startLab;
@property (nonatomic, strong) UILabel *startDateLab;
@property (nonatomic, strong) UILabel *endLab;
@property (nonatomic, strong) UILabel *endDateLab;
@property (nonatomic, strong) UIImageView *iconImageV;
@property (nonatomic, strong) UIButton *startDateBtn;
@property (nonatomic, strong) UIButton *endDateBtn;

@property (nonatomic, strong) UITableView *tableView;
@property (nonatomic, strong) NSDateFormatter *dateFormatter;
@property (nonatomic, strong) UIView *tipView;
@property (nonatomic, assign) NSInteger currentPage;
@property (nonatomic, strong) UILabel *allShopLab;
@property (nonatomic, strong) UIImageView *allowImageV2;

@property (nonatomic, strong) SASystemStoreStoreListAPI *systemStoreStoreListAPI;
@property (nonatomic, strong) NSMutableArray<SAStoreModel *> *storeList;
@property (nonatomic, strong) BubbleTableView *storeBubbleView;
@property (nonatomic, assign) NSInteger storeRow;
@property (nonatomic, strong) NSMutableArray<SAMemberTopUpRecordModel *> *dataMarr;
@property (nonatomic, strong) SAMemberQueryRechargeAPI *memberQueryRechargeAPI;
@property (nonatomic, assign) BOOL isFrist;//第一次展示店铺信息

@property (nonatomic, strong) UILabel *topUpNumLab;
@property (nonatomic, strong) UILabel *topUpTotalLab;
@property (nonatomic, strong) UILabel *topUpGiveLab;


@end

@implementation SAMemberTopUpRecordVC

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
}

#pragma mark - HTTPAPIDelegate
- (void)fetchData:(id)data fromServerSuccessedWithAPI:(HTTPAPI *)api {
    [self.tableView.mj_header endRefreshing];
    [self.tableView.mj_footer endRefreshing];
    if (self.systemStoreStoreListAPI == api) {
        self.storeList = [SAStoreModel mj_objectArrayWithKeyValuesArray:data[@"data"]];
        for (NSInteger i = 0; i < self.storeList.count; i++) {
            if ([SAValueManger shareInStance].userInfo.merchantId == self.storeList[i].merchantId) {
                self.storeRow = i;
            }
        }
        if (self.isFrist != YES) {
            [self showStoreList];
        }else {
            self.isFrist = NO;
        }
        
    }else if (self.memberQueryRechargeAPI == api) {
        if (self.currentPage == 1) {
            self.dataMarr = [SAMemberTopUpRecordModel mj_objectArrayWithKeyValuesArray:data[@"data"][@"records"]];
            if (self.dataMarr.count > 1) {
                NSString *totalRecords =  data[@"data"][@"totalRecords"];
                NSString *rechargeAmount =  data[@"data"][@"obj"][@"rechargeAmount"];
                NSString *giveAmount =  data[@"data"][@"obj"][@"giveAmount"];
                
                self.topUpNumLab.text = [NSString stringWithFormat:@"%@",totalRecords];;
                self.topUpTotalLab.text = [NSString stringWithFormat:@"%0.2lf",[rechargeAmount doubleValue]/100];
                self.topUpGiveLab.text = [NSString stringWithFormat:@"%0.2lf",[giveAmount doubleValue]/100];
            }
        }else {
            for (NSDictionary *dict in (NSArray *)data[@"data"][@"records"]) {
                SAMemberTopUpRecordModel *model = [SAMemberTopUpRecordModel mj_objectWithKeyValues:dict];
                [self.dataMarr addObject:model];
            }
        }
        [self.tableView reloadData];
        self.tipView.hidden = self.dataMarr.count > 0;
    }
}

- (void)fetchDataFromServerFailedWithError:(NSError *)error API:(HTTPAPI *)api {
    [self.tableView.mj_header endRefreshing];
    [self.tableView.mj_footer endRefreshing];
}

#pragma mark - UITableView Delegate & DataSource
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
    return self.dataMarr.count;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    return 1;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    SAMemberTopUpRecordCell *cell = [tableView dequeueReusableCellWithIdentifier:@"SAMemberTopUpRecordCell"];
    cell.model = self.dataMarr[indexPath.section];
    return cell;
}

-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {

}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
    return kScaleNum(70);
}

- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section {
    return [[UIView alloc] initWithFrame:CGRectZero];
}

- (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section {
    return [[UIView alloc] initWithFrame:CGRectZero];
}

-(CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section {
    return kScaleNum(0.01);
}

-(CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section {
    return 1;
}

#pragma mark - event
-(void)loadData {
    self.memberQueryRechargeAPI.currentPage = self.currentPage;
    [self.memberQueryRechargeAPI sendRequestToServerWithActivityViewAndMask:POST];
}

- (void)clickStartDateBtn:(UIButton *)btn {
    WeakSelf
    HDDatePickerView *pickerView = [[HDDatePickerView alloc] initWithSlectedDate:self.startDateLab.text];
    [pickerView show];
    pickerView.selectDateBlock = ^(NSString *selectedDate) {
        NSDate *date1 = [self.dateFormatter dateFromString:selectedDate];
        NSDate *date2 = [self.dateFormatter dateFromString:weakSelf.endDateLab.text];
        if ([date1 compare:date2] == NSOrderedDescending) {
            [Prompt popPromptViewWithMsg:@"开始日期不能大于截止日期" duration:2];
        }else {
            weakSelf.startDateLab.text = selectedDate;
            weakSelf.currentPage = 1;
            weakSelf.memberQueryRechargeAPI.startTime = selectedDate;
            [weakSelf loadData];
        }
    };
}

- (void)clickEndDateBtn:(UIButton *)btn {
    WeakSelf
    HDDatePickerView *pickerView = [[HDDatePickerView alloc] initWithSlectedDate:self.endDateLab.text];
    [pickerView show];
    pickerView.selectDateBlock = ^(NSString *selectedDate) {
        NSDate *date1 = [self.dateFormatter dateFromString:selectedDate];
        NSDate *date2 = [self.dateFormatter dateFromString:weakSelf.startDateLab.text];
        if ([date1 compare:date2] == NSOrderedAscending) {
            [Prompt popPromptViewWithMsg:@"截止日期不能小于开始日期" duration:2];
        }else {
            weakSelf.endDateLab.text = selectedDate;
            weakSelf.currentPage = 1;
            weakSelf.memberQueryRechargeAPI.endTime = selectedDate;
            [weakSelf loadData];
        }
    };
}

-(void)clickedAllowBtn2 {
    NSMutableArray *menuList = [SAValueManger shareInStance].userInfo.menuList;
    NSString *crossStoreMember = [NSString stringWithFormat:@"%@",menuList[6][@"perms"][@"crossStoreMember"]];
    if ([crossStoreMember isEqualToString:@"1"]) {
        [Prompt popPromptViewWithMsg:@"您没有跨店查会员权限,请联系店长添加" duration:2];
        return;
    }

    if (self.storeList.count > 0) {
        [self showStoreList];
    }else {
        [self.systemStoreStoreListAPI sendRequestToServerWithActivityViewAndMask:GET];
    }
}
    
-(void)showStoreList{
    NSMutableArray *marr = [NSMutableArray array];
    for (SAStoreModel *model in self.storeList) {
        if (model.storeName.length == 0) {
            model.storeName = @"";
        }
        [marr addObject:model.storeName];
    }
    NSInteger height = marr.count * 50 + 10;
    if (height > 190) {
        height = 190;
    }
    NSArray *arr = nil;
    UIView *window = [UIApplication sharedApplication].keyWindow;
    if (!self.storeBubbleView) {
        self.storeBubbleView = [[BubbleTableView alloc] initWithLocation:(BubbleLocationDown) bubbleAlignment:(BubbleAlignmentRight) width:120 height:height cellClickBlock:^(NSInteger row, NSString * _Nonnull rowString, NSArray *fromDataArray) {
            self.storeRow = row;
            self.memberQueryRechargeAPI.merchantId = @(self.storeList[row].merchantId).stringValue;
            self.allShopLab.text = rowString;
            self.currentPage = 1;
            self.memberQueryRechargeAPI.currentPage = 1;
            [self loadData];
        } hideBlock:^{
            self.storeBubbleView = nil;
        }];
        [self.storeBubbleView showWithTargetView:self.allowImageV2 maskSuperView:window];
        [self.storeBubbleView updateBubble:marr fromDataArray:arr];// 更新气泡弹框
        self.storeBubbleView.bubbleCellHeight = 50;
        self.storeBubbleView.selectRow = self.storeRow;
        self.storeBubbleView.isBubbleScrollEnabled = YES;
        self.storeBubbleView.bubbleCellTextAlignment = NSTextAlignmentCenter;
    }
}

-(void)clickedSearchBtn {
//    __weak typeof(self) weakSelf = self;
    SATopUpScreeningView *screenView = [SATopUpScreeningView shareCornView];
    [screenView showView:self];
}

#pragma mark - initUI
-(void)initUI {
    [self setNavigationItemBackBBIAndTitle:@"会员充值记录"];
    [self setBgImage:nil];
    self.view.backgroundColor = kBgColor;
    
    UIButton *searchBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    searchBtn.frame = CGRectMake(0, 0, kScaleNum(60), kScaleNum(44));
    [searchBtn setImage:[UIImage imageNamed:@"Sale_screen"] forState:UIControlStateNormal];
    [searchBtn addTarget:self action:@selector(clickedSearchBtn) forControlEvents:UIControlEventTouchUpInside];
//    [self addRightViews:@[searchBtn]];
    
    [self.view addSubview:self.topContentView];
    [self.topContentView addSubview:self.startLab];
    [self.topContentView addSubview:self.startDateLab];
    [self.topContentView addSubview:self.endLab];
    [self.topContentView addSubview:self.endDateLab];
    [self.topContentView addSubview:self.iconImageV];
    [self.topContentView addSubview:self.startDateBtn];
    [self.topContentView addSubview:self.endDateBtn];
    
    [self.topContentView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(kScaleNum(StatusHeight));
        make.height.mas_equalTo(kScaleNum(44));
        make.right.mas_equalTo(0);
        make.left.mas_equalTo(kScaleNum(0));
    }];
    
    [self.iconImageV mas_makeConstraints:^(MASConstraintMaker *make) {
        make.center.mas_equalTo(0);
        make.size.mas_equalTo(CGSizeMake(29, 29));
    }];
    
    [self.startLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.startDateLab);
        make.top.mas_equalTo(kScaleNum(2));
        make.height.mas_equalTo(kScaleNum(20));
    }];
    
    [self.startDateLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.equalTo(self.iconImageV.mas_left).offset(kScaleNum(-68));
        make.top.mas_equalTo(kScaleNum(22));
        make.height.mas_equalTo(kScaleNum(20));
    }];
    
    [self.endLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.endDateLab);
        make.top.mas_equalTo(kScaleNum(2));
        make.height.mas_equalTo(kScaleNum(20));
    }];
    
    [self.endDateLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.iconImageV.mas_right).offset(kScaleNum(68));
        make.top.mas_equalTo(kScaleNum(22));
        make.height.mas_equalTo(kScaleNum(20));
    }];
    
    [self.startDateBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.equalTo(self.startDateLab);
        make.top.bottom.mas_equalTo(0);
    }];
    
    [self.endDateBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.equalTo(self.endDateLab);
        make.top.bottom.mas_equalTo(0);
    }];
    
    NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
    [dateFormatter setDateFormat:@"yyyy-MM-dd"];
    NSString *timeFormatStr = [dateFormatter stringFromDate:[NSDate date]];
    _startDateLab.text = timeFormatStr;
    _endDateLab.text = timeFormatStr;
    
    UIView *grayView = [[UIView alloc] initWithFrame:SARectMake(0, StatusHeight + 44, kBaseScreenWidth, 35)];
    grayView.backgroundColor = kTextBgColor;
    [self.view addSubview:grayView];
    
    UILabel *allShopLab = [[UILabel alloc] init];
    allShopLab.text =[SAValueManger shareInStance].userInfo.storeName;
    allShopLab.font = kBFont(15);
    allShopLab.textColor = kBlackColor;
    [grayView addSubview:allShopLab];
    self.allShopLab = allShopLab;
    
    UIImageView *allowImageV2 = [[UIImageView alloc] init];
    allowImageV2.image = [UIImage imageNamed:@"bule_downAllow"];
    [grayView addSubview:allowImageV2];
    allowImageV2.contentMode = UIViewContentModeCenter;
    self.allowImageV2 = allowImageV2;
    
    UIButton *allowBtn2 = [UIButton buttonWithType:UIButtonTypeCustom];
    [allowBtn2 addTarget:self action:@selector(clickedAllowBtn2) forControlEvents:UIControlEventTouchUpInside];
    [grayView addSubview:allowBtn2];
    
    [allShopLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(0);
        make.left.mas_equalTo(kScaleNum(25));
        make.height.mas_equalTo(kScaleNum(35));
        make.width.mas_lessThanOrEqualTo(kScaleNum(150));
        make.width.mas_greaterThanOrEqualTo(kScaleNum(50));
    }];
    
    [allowImageV2 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(0);
        make.height.mas_equalTo(kScaleNum(35));
        make.width.mas_equalTo(kScaleNum(55));
        make.left.mas_equalTo(allShopLab.mas_right).offset(kScaleNum(-10));
    }];
    
    [allowBtn2 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.left.mas_equalTo(0);
        make.height.mas_equalTo(kScaleNum(35));
        make.right.mas_equalTo(allShopLab.mas_right).offset(kScaleNum(30));
    }];

    UIView *whiteView = [[UIView alloc] initWithFrame:CGRectMake(0, kScaleNum(StatusHeight + 79), kScreenWidth, kScaleNum(48))];
    whiteView.backgroundColor = [UIColor whiteColor];
    [self.view addSubview:whiteView];
    
    UILabel *topUpNumLab = [[UILabel alloc] initWithFrame:CGRectMake(0, kScaleNum(7), kScaleNum(125), kScaleNum(15))];
    topUpNumLab.text = @"0";
    topUpNumLab.textColor = kPinkColor;
    topUpNumLab.font = kFont(15);
    topUpNumLab.textAlignment = NSTextAlignmentCenter;
    [whiteView addSubview:topUpNumLab];
    self.topUpNumLab = topUpNumLab;
    
    UILabel *topUpNumTitleLab = [[UILabel alloc] initWithFrame:CGRectMake(0, kScaleNum(26), kScaleNum(125), kScaleNum(15))];
    topUpNumTitleLab.text = @"充值数";
    topUpNumTitleLab.textColor = kBlackColor;
    topUpNumTitleLab.font = kFont(15);
    topUpNumTitleLab.textAlignment = NSTextAlignmentCenter;
    [whiteView addSubview:topUpNumTitleLab];
    
    UILabel *topUpTotalLab = [[UILabel alloc] initWithFrame:CGRectMake(kScaleNum(125), kScaleNum(7), kScaleNum(125), kScaleNum(15))];
    topUpTotalLab.text = @"0";
    topUpTotalLab.textColor = kPinkColor;
    topUpTotalLab.font = kFont(15);
    topUpTotalLab.textAlignment = NSTextAlignmentCenter;
    [whiteView addSubview:topUpTotalLab];
    self.topUpTotalLab = topUpTotalLab;
    
    UILabel *topUpTotalTitleLab = [[UILabel alloc] initWithFrame:CGRectMake(kScaleNum(125), kScaleNum(26), kScaleNum(125), kScaleNum(15))];
    topUpTotalTitleLab.text = @"充值额";
    topUpTotalTitleLab.textColor = kBlackColor;
    topUpTotalTitleLab.font = kFont(15);
    topUpTotalTitleLab.textAlignment = NSTextAlignmentCenter;
    [whiteView addSubview:topUpTotalTitleLab];
    
    UILabel *topUpGiveLab = [[UILabel alloc] initWithFrame:CGRectMake(kScaleNum(250), kScaleNum(7), kScaleNum(125), kScaleNum(15))];
    topUpGiveLab.text = @"0";
    topUpGiveLab.textColor = kPinkColor;
    topUpGiveLab.font = kFont(15);
    topUpGiveLab.textAlignment = NSTextAlignmentCenter;
    [whiteView addSubview:topUpGiveLab];
    self.topUpGiveLab = topUpGiveLab;
    
    UILabel *topUpGiveTitleLab = [[UILabel alloc] initWithFrame:CGRectMake(kScaleNum(250), kScaleNum(26), kScaleNum(125), kScaleNum(15))];
    topUpGiveTitleLab.text = @"赠送金额";
    topUpGiveTitleLab.textColor = kBlackColor;
    topUpGiveTitleLab.font = kFont(15);
    topUpGiveTitleLab.textAlignment = NSTextAlignmentCenter;
    [whiteView addSubview:topUpGiveTitleLab];
    
    [self.view addSubview:self.tableView];
    [self.view addSubview:self.tipView];
    
    __weak typeof(self) weakSelf = self;
    self.tableView.mj_header = [MJRefreshNormalHeader headerWithRefreshingBlock:^{
        [weakSelf.view endEditing:YES];
        weakSelf.currentPage = 1;
        [weakSelf loadData];
    }];
    MJRefreshAutoStateFooter *mj_footer = [MJRefreshAutoStateFooter footerWithRefreshingBlock:^{
        [weakSelf.view endEditing:YES];
        weakSelf.currentPage ++;
        [weakSelf loadData];
    }];
    [mj_footer setTitle:@"已经到底啦~" forState:MJRefreshStateIdle];//设置闲置状态下不显示“点击或上拉加载更多”
    self.tableView.mj_footer = mj_footer;
    
    self.currentPage = 1;
    self.memberQueryRechargeAPI.pageSize = 20;
    self.memberQueryRechargeAPI.startTime = timeFormatStr;
    self.memberQueryRechargeAPI.endTime = timeFormatStr;
    self.memberQueryRechargeAPI.merchantId = @([SAValueManger shareInStance].userInfo.merchantId).stringValue;
    [self loadData];
    
    self.isFrist = YES;
    self.systemStoreStoreListAPI.returnAll = @"true";
    [self.systemStoreStoreListAPI sendRequestToServerWithActivityViewAndMask:GET];
}

#pragma mark - lazy
- (UIView *)topContentView {
    if (!_topContentView) {
        _topContentView = [[UIView alloc] init];
        _topContentView.backgroundColor = [UIColor whiteColor];
    }
    return _topContentView;
}

- (UILabel *)startLab {
    if (!_startLab) {
        _startLab = [[UILabel alloc] init];
        _startLab.textColor = kBlackColor;
        _startLab.font = kFont(15);
        _startLab.text = @"开始";
    }
    return _startLab;
}

- (UILabel *)startDateLab {
    if (!_startDateLab) {
        _startDateLab = [[UILabel alloc] init];
        _startDateLab.textColor = kBlackColor;
        _startDateLab.font = kFont(15);
    }
    return _startDateLab;
}

- (UILabel *)endLab {
    if (!_endLab) {
        _endLab = [[UILabel alloc] init];
        _endLab.textColor = kBlackColor;
        _endLab.font = kFont(15);
        _endLab.text = @"截止";
    }
    return _endLab;
}

- (UILabel *)endDateLab {
    if (!_endDateLab) {
        _endDateLab = [[UILabel alloc] init];
        _endDateLab.textColor = kBlackColor;
        _endDateLab.font = kFont(15);
    }
    return _endDateLab;
}

- (UIImageView *)iconImageV {
    if (!_iconImageV) {
        _iconImageV = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"SA_to"]];
    }
    return _iconImageV;
}

- (UIButton *)startDateBtn {
    if (!_startDateBtn) {
        _startDateBtn = [UIButton buttonWithType:UIButtonTypeCustom];
        [_startDateBtn addTarget:self action:@selector(clickStartDateBtn:) forControlEvents:UIControlEventTouchUpInside];
    }
    return _startDateBtn;
}

- (UIButton *)endDateBtn {
    if (!_endDateBtn) {
        _endDateBtn = [UIButton buttonWithType:UIButtonTypeCustom];
        [_endDateBtn addTarget:self action:@selector(clickEndDateBtn:) forControlEvents:UIControlEventTouchUpInside];
    }
    return _endDateBtn;
}

-(UITableView *)tableView {
    if (!_tableView) {
        _tableView = [[UITableView alloc] initWithFrame:CGRectMake(0, kScaleNum(StatusHeight + 128), kScreenWidth, kScreenHeight - kScaleNum(StatusHeight + 128)) style:UITableViewStyleGrouped];
        _tableView.backgroundColor = kLineColor;
        _tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
        _tableView.delegate = self;
        _tableView.dataSource = self;
        _tableView.showsHorizontalScrollIndicator = NO;
        if (@available(iOS 11.0, *)) {
            _tableView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;
        }
        _tableView.estimatedRowHeight = 0;
        _tableView.estimatedSectionHeaderHeight = 0;
        _tableView.estimatedSectionFooterHeight = 0;
        [_tableView registerClass:[SAMemberTopUpRecordCell class] forCellReuseIdentifier:@"SAMemberTopUpRecordCell"];
    }
    return _tableView;
}

-(UIView *)tipView {
    if (!_tipView) {
        _tipView = [[UIView alloc] initWithFrame:CGRectMake(0, kScaleNum(StatusHeight + 79), kScreenWidth, kScreenHeight - kScaleNum(StatusHeight + 79))];
        _tipView.backgroundColor = [UIColor whiteColor];
        UIImageView *icon = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"Shop_search2"]];
        icon.frame = SARectMake(124, 106, 138, 83);
        [_tipView addSubview:icon];
        UILabel *titleLab = [[UILabel alloc] initWithFrame:CGRectMake(0, icon.maxY + kScaleNum(20), _tipView.width, kScaleNum(20))];
        titleLab.text = @"暂无相关信息";
        titleLab.textAlignment = NSTextAlignmentCenter;
        titleLab.textColor = kGrayColor;
        [_tipView addSubview:titleLab];
    }
    return _tipView;
}

-(NSDateFormatter *)dateFormatter {
    if (!_dateFormatter) {
        _dateFormatter = [NSDateFormatter new];
        [_dateFormatter setDateFormat:@"yyyy-MM-dd"];
    }
    return _dateFormatter;
}

-(SASystemStoreStoreListAPI *)systemStoreStoreListAPI {
    if (!_systemStoreStoreListAPI) {
        _systemStoreStoreListAPI = [SASystemStoreStoreListAPI apiWithDelegate:self];
    }
    return _systemStoreStoreListAPI;
}

-(NSMutableArray<SAStoreModel *> *)storeList {
    if (!_storeList) {
        _storeList = [NSMutableArray array];
    }
    return _storeList;
}

-(NSMutableArray<SAMemberTopUpRecordModel *> *)dataMarr {
    if (!_dataMarr) {
        _dataMarr = [NSMutableArray array];
    }
    return _dataMarr;
}

-(SAMemberQueryRechargeAPI *)memberQueryRechargeAPI {
    if (!_memberQueryRechargeAPI) {
        _memberQueryRechargeAPI = [SAMemberQueryRechargeAPI apiWithDelegate:self];
    }
    return _memberQueryRechargeAPI;
}

@end
